package com.csist.service.impl;

import com.csist.mapper.UserMapper;
import com.csist.pojo.bo.User;
import com.csist.service.UserService;
import com.csist.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

/**
 * @ClassName UserServiceImpl
 * @Description 【用户业务接口实现】
 * @Author T
 * @Date 2024/6/24 15:50
 * @Version 1.0
 */
public class UserServiceImpl implements UserService {
    private SqlSession sqlSession;
    private UserMapper userMapper;

    public UserServiceImpl() {
        sqlSession = SqlSessionUtil.openSession();
        userMapper = sqlSession.getMapper(UserMapper.class);
    }

    /**
     * 用户登录
     * @param account 账号
     * @param password 密码
     * @return
     */
    @Override
    public User login(String account, String password) {
        User user = userMapper.selcetByUserName(account);
        if (user != null && !password.equals(user.getUiPwd())) {
            return null;
        }
        return user;
    }
}
